home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 020 / porthandler / poster < prev    next >
Text File  |  1995-03-17  |  4KB  |  86 lines

  1. Article 1260 of net.micro.amiga:
  2. Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site unisoft.UUCP
  3. Path: unisoft!lll-lcc!qantel!intelca!oliveb!glacier!decwrl!decvax!mcnc!ncsu!jcz
  4. From: jcz@ncsu.UUCP (John A. Toebes, VIII)
  5. Newsgroups: net.micro.amiga
  6. Subject: AmigaDos Port-Handler (long)
  7. Message-ID: <3074@ncsu.UUCP>
  8. Date: 1 Apr 86 05:23:24 GMT
  9. Date-Received: 2 Apr 86 11:15:29 GMT
  10. Organization: SAS Institute Inc.
  11. Lines: 578
  12.  
  13. As promised before, here is my version of the Port-Handler for AmigaDos.
  14. It was derived in part from looking at the original Port-Handler in order
  15. to obtain the calling conventions of BCPL and the routines that must be
  16. called in order to do I/O through the BCPL environment, but otherwise
  17. I started from scratch (and an empty file) to code it.
  18.  
  19. My original goal was to learn out exactly how AmigaDos device handlers are 
  20. constructed and as such I have learned enough from writing this one that I
  21. have also written a PIPE: handler to implement *REAL* UN*X pipes.  It
  22. is not completely tested, so I expect it will be a week or so before I
  23. would consider posting it.
  24.  
  25. Now on to how this one works:  I have tested it with the majority of the 
  26. AmigaDos commands and have yet to get it to fail, but I have one instance
  27. in a print program where it locks up.  Because of that, this program is NOT
  28. to be taken as a direct replacement for the supplied Port-Handler until I
  29. can track down that bug.  The true value of this code is that it shows what
  30. the BCPL environment looks like from the handler point of view.
  31.  
  32. I will be posting a tutorial on the BCPL environment in about 2 weeks, but a
  33. quick summary of the conventions:
  34.     Upon entry to a BCPL routine (Including all command programs!) the
  35. registers are set up as:
  36.      A0 - Contains 0
  37.      A1 - Points to the Bottom of the BCPL global stack
  38.      A2 - Points to the internal AmigaDos library!
  39.      A3 - ?unknown - I believe it to be unused
  40.      A4 - Points to the Base of your code - I.E. Entry address
  41.      A5 - Points to a service vector for calling other BCPL routines
  42.      A6 - Points to the service vector to return from a routines
  43.      A7 - Points to the program stack
  44.      D0 - Generally unimportant - contains the size of the caller's global area
  45.      D1-D4 - Contain first 4 (if that many) parameters
  46.      D5-D7 - Unused
  47. To call a BCPL routine you must:
  48.   Load the parameters into D1-D4 respectively
  49.   Load D0 with the size of your global stack
  50.   Load A4 with the address of the routine to call
  51.   JSR (A5)
  52. To exit a BCPL routine you simply
  53.   JSR (A6)
  54. In general, A2 points to an internal AmigaDos library that WILL PROBABLY CHANGE
  55. with the next release of Workbench/AmigaDos, but to what extent is unknown.
  56. So as such, the calls described here must be used with NO SUPPORT even implied
  57. by Commodore (They didn't document them so why should they stay?).  However
  58. on the other side of the coin you would never get along without them.
  59. I have figured out some of them as listed in the include file BCPL.I and will
  60. document them later.  For now, the parameters should be fairly simple to
  61. deduce from the code.
  62.  
  63. Once you have assembled and linked the code, it is invoked by simply replacing
  64. the system PORT-HANDLER in the L: directory and then accessing any of PAR:
  65. SER: or PRT:.  AmigaDos will automatically load and run the handler.  Note that
  66. because this process is automatic, it is next to impossible to debug.  As such
  67. you see the commented out debug statements in the code to store into the stack
  68. frame and at $CA so that you can look at where the process is through WACK.
  69. It is not an easy task, so expect to poke around a bit.
  70.  
  71. This code is being released for personal consumption only.  I am not supporting
  72. this version (remember it has a known bug) but it should serve to show exactly
  73. what an AmigaDos handler has to do.  I have not been able to get any
  74. verification of correctness from Commodore or even a condonement/condeming
  75. from them so this could be way off base (But I seriously doubt it).
  76. Good Luck...
  77.  
  78. John A. Toebes, VIII
  79. 120 H Northington Place
  80. Cary NC 27511
  81. (919) 469-4210
  82.  ...mcnc!ncsu!jcz   (as a guest there)
  83.  
  84. Disclaimer: I don't know what I am doing so how can you expect anyone else
  85. to be responsible for what I say and do.
  86.